<template>
	<!-- 歌单 -->
	<scroll-view scroll-x scroll-with-animation class="song-sheet zy-list" >
		<view class="list-item" v-for="item in favoriteList" :key="item.id">
			<!-- 播放量 -->
			<view class="hotCount" v-if="item.playCount>0">
				<text class="iconfont icon-kaishi" style="margin-right: 3.5px;"></text>
				<text>{{filterPlayCount(item.playCount||item.playcount)}}</text>
			</view>

			<view class="bg-img flex align-end list-item-image" :style="'background-image:url('+item.picUrl+')'">
				
			</view>
			<view class="list-item-text">{{item.name}}</view>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		data() {
			return {
				favoriteList: []
			};
		},
		onLoad() {
			uni.request({
				url: 'https://autumnfish.cn/personalized',
				success: (res) => {
					this.favoriteList = res.data.result;
					console.log(this.favoriteList)
				}
			})
		},
		methods: {
			filterPlayCount(val) {
				if (!val || val <= 0) return 0
				else if (val < 1000) return val
				else if (val >= 1000 && val < 10000) return Math.ceil(val / 1000) + '千'
				else if (val >= 10000 && val < 100000000) return Math.ceil(val / 10000) + '万'
				return Math.ceil(val / 100000000) + '亿'
			}
		}
	}
</script>

<style lang="scss" scoped>
	//歌单
	.song-sheet {
		white-space: nowrap;
		.list-item {
			width: 27.5%;
			margin: 0 6px;
			display: inline-block;
			overflow: hidden;
			position: relative;

			.hotCount {
				position: absolute;
				width: 100%;
				height: 50px;
				padding: 3px 6px 0 0;
				text-align: right;
				color: #fff;
				z-index: 10;
				font-size: 12px;
			}

			.list-item-image {
				height: 115px;
				border-radius: 10px;
			}

			.list-item-text {
				height: 35px;
				width: 100%;
				padding-top: 2px;
				white-space: normal;
				color: #666;
				font-size: 12px;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
			}
		}
	}
</style>
